package com.example.myapplication;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class DBHelper extends SQLiteOpenHelper {
    private static final String DB_NAME="ThingAppDatabase";
    private static final String CREATE_THING_TABLE = "create table Thing ( "+
            "id integer primary key autoincrement,"+
            "name text,"+
            "count integer,"+
            "unit integer,"+
            "type1 integer,"+
            "imagepath text,"+
            "position text,"+
            "information text,"+
            "date integer"+
            ")";
    private static final String CREATE_UNIT_TABLE="create table Unit("+
            "id integer primary key autoincrement,"+
            "name text"+
            ")";
    private static final String CREATE_TYPE_FIRST="create table TypeFirst("+
            "id integer primary key autoincrement,"+
            "name text"+
            ")";

    private static final String CREATE_ISFIRSTUSE_TABLE="create table IsFirstUse("+
            "id integer primary key,"+
            "isfirstuse bool"+
            ")";
    public DBHelper(@Nullable Context context,  @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, DB_NAME, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        sqLiteDatabase.execSQL(CREATE_THING_TABLE);
        sqLiteDatabase.execSQL(CREATE_UNIT_TABLE);
        sqLiteDatabase.execSQL(CREATE_TYPE_FIRST);
        sqLiteDatabase.execSQL(CREATE_ISFIRSTUSE_TABLE);
        sqLiteDatabase.execSQL("insert into IsFirstUse values(1,true)");
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

    }
}
